#include <cstdio>
#include <memory.h>
#include <queue>
using namespace std;

vector<int> G[1005];
bool vis[1005];

bool bfs(int x) {
	queue<int> q;
	q.push(x);
	bool flag = 0;
	while (q.size()) {
		int now = q.front();
		q.pop();
		if (now == x && flag) return 1;

		if (vis[now]) continue;
		vis[now] = 1;
		flag = 1;
		for (int i = 0; i < G[now].size(); ++i) {
			q.push(G[now][i]);
		}
	}
	return 0;
}

int main() {
	int m, n, a, b;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		scanf("%d %d", &a, &b);
		G[a].push_back(b); 
	}

	for (int i = 1; i <= n; ++i) {
		if (bfs(i)) {
			printf("T\n");
		} else {
			printf("F\n");
		}
		memset(vis, 0, sizeof(vis));
	}

	return 0;
}